home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sound / tiaintf.c < prev    next >
C/C++ Source or Header  |  2000-02-09  |  1KB  |  62 lines

  1. /***************************************************************************
  2.  
  3.    tiaintf.c
  4.  
  5.    Interface the routines in tiasound.c to MESS
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "sound/tiasound.h"
  11. #include "sound/tiaintf.h"
  12.  
  13. #define MIN_SLICE 10    /* minimum update step */
  14.  
  15. #define BUFFER_LEN 8192
  16.  
  17. static unsigned int sample_pos;
  18.  
  19. static int channel;
  20.  
  21. static const struct TIAinterface *intf;
  22. static INT16 *buffer;
  23.  
  24. int tia_sh_start(const struct MachineSound *msound)
  25. {
  26. //    int i, res;
  27.  
  28.     intf = msound->sound_interface;
  29.  
  30.     if (Machine->sample_rate == 0) return 0;
  31.     sample_pos = 0;
  32.  
  33.     channel = mixer_allocate_channel(intf->volume);
  34.  
  35.     if ((buffer = malloc(sizeof(INT16) * BUFFER_LEN)) == 0)
  36.         return 1;
  37.     memset(buffer,0,sizeof(INT16) * BUFFER_LEN);
  38.  
  39.     Tia_sound_init (intf->clock, Machine->sample_rate);
  40.     return 0;
  41. }
  42.  
  43.  
  44. void tia_sh_stop (void)
  45. {
  46.     /* Nothing to do here */
  47. }
  48.  
  49. void tia_sh_update (void)
  50. {
  51.     int buflen;
  52.  
  53.     if (Machine->sample_rate == 0) return;
  54.  
  55.     buflen = mixer_samples_this_frame();
  56.     if (sample_pos < buflen)
  57.         Tia_process (buffer + sample_pos, buflen - sample_pos);
  58.     sample_pos = 0;
  59.  
  60.     mixer_play_streamed_sample_16(channel,buffer,2*buflen,Machine->sample_rate);
  61. }
  62.